package edu.mercer.sse.ldap;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

/**
 * 
 * LDAP Host, login information.<p>
 *
 */

public class LDAPCredentials
{
	private String _ldapHost = "";
	
	private Integer _ldapPort = 0;

	private String _ldapAdmin = "";

	private String _ldapPassword = "";


	/**
	 * 
	 * LDAP Host, login information.<p>
	 *
	 */

	public LDAPCredentials() {}//constructor
	
	
	String host(){ return _ldapHost; }
	
	Integer port(){ return _ldapPort; }
	
	String admin(){ return _ldapAdmin; }
	
	String password(){ return _ldapPassword; }
	
	
	public LDAPCredentials withHost( final String host )
	{
		checkNotNull( host, "ldap hostname null" );
		
		_ldapHost = host;
		
		return this;
		
	}//method


	public LDAPCredentials withPort( final Integer port )
	{
		checkArgument( port > 0, "ldap port not set" );
		
		_ldapPort = port;
		
		return this;
		
	}//method

	
	public LDAPCredentials withAdmin( final String admin )
	{
		checkNotNull( admin, "ldap admin dn null" );
		
		_ldapAdmin = admin;
		
		return this;
		
	}//method

	
	public LDAPCredentials withPassword( final String password )
	{
		checkNotNull( password, "ldap password dn null" );
		
		_ldapPassword = password;
		
		return this;
		
	}//method

	
	public Boolean isSet()
	{
		if( _ldapPassword != null 		&& 
			_ldapPassword.length() > 0  &&
			
			_ldapAdmin != null 			&&
			_ldapAdmin.length() > 0 	&&
			
			_ldapHost != null 			&&
			_ldapHost.length() > 0 		&&
			
			_ldapPort != null 			&&
			_ldapPort > 0)
		{
			return true;
			
		}//if
		
		return false;
		
	}//method
	
	
}//class
